/*
 * Copyright 2009 SHOP.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.shop.opensocial.mediated.shindig.factories;

import net.oauth.OAuthConsumer;
import com.shop.opensocial.mediated.types.OAuthConsumerMediator;
import com.shop.opensocial.mediated.types.OAuthServiceProviderMediator;

/**
 * Factory for converting between Mediator type and Shindig type
 *
 * @author Jordan Zimmerman
 */
public class OAuthConsumerMediatorFactory extends GenericMediatorFactory<OAuthConsumer, OAuthConsumerMediator>
{
	public static final GenericMediatorFactoryBase<OAuthConsumer, OAuthConsumerMediator>		i = new OAuthConsumerMediatorFactory();

	@Override
	protected OAuthConsumer internalMake(OAuthConsumerMediator c)
	{
		return new OAuthConsumer(c.getCallbackURL(), c.getConsumerKey(), c.getConsumerSecret(), OAuthServiceProviderMediatorFactory.i.make(c.getServiceProvider()));
	}

	@Override
	protected OAuthConsumerMediator internalUnmake(final OAuthConsumer c)
	{
		return new OAuthConsumerMediator()
		{
			@Override
			public String getCallbackURL()
			{
				return c.callbackURL;
			}

			@Override
			public String getConsumerKey()
			{
				return c.consumerKey;
			}

			@Override
			public String getConsumerSecret()
			{
				return c.consumerSecret;
			}

			@Override
			public OAuthServiceProviderMediator getServiceProvider()
			{
				return OAuthServiceProviderMediatorFactory.i.unmake(c.serviceProvider);
			}
		};
	}
}
